package com.fxkj.cloud.drms.infra.mq.mqtt.sender;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fxkj.cloud.dbs.common.model.ControlOrder;
import com.fxkj.common.utils.JacksonUtil;

import java.util.List;
import java.util.UUID;

/**
 * <p>description: </p>
 * @author ww
 * @date 2025/4/21 11:27
 */

public class ControlPlanMqttCommand extends BaseMqttMessage<ControlOrder> {

    public ControlPlanMqttCommand(UUID requestId, List<ControlOrder> data) {
        super(requestId, data);
    }

    public static ControlPlanMqttCommand create(UUID requestId, List<ControlOrder> data) {
        return new ControlPlanMqttCommand(requestId, data);
    }

    public String toJsonString() throws JsonProcessingException {
        ObjectNode node = new ObjectNode(JsonNodeFactory.instance);
        node.put("requestId", this.getRequestId().toString());

        return JacksonUtil.getObjectMapperWithJavaTimeModule().writeValueAsString(this);
    }
}
